// 一般在这里做对数据库的增删改查
import { Injectable } from '@nestjs/common';
// 与实体进行连接进行操作数据库，引入数据库仓库，注入仓库，数据库实体
import { Girl } from "./entities/girl.entity"
import { GirlDetail } from './entities/girlDetail.entity';
import { InjectRepository } from '@nestjs/typeorm';
import { Like, Repository } from 'typeorm';
@Injectable()
export class GirlService {
    // 先对实体进行依赖注入
    constructor(@InjectRepository(Girl) private readonly girl:Repository<Girl>)
    {}
    addGirl(){
        const data=new Girl();
        data.name="大雅ya"
        data.age=58;
        data.skill='按摩'
        return this.girl.save(data);
        // return this.
        // console.log("数据库实体",this.girl)
    }
     delGirl(id:number){
        return this.girl.delete(id);
     }
     updateGirl(id:number){
        const data=new Girl();
        data.name="liuxiaolan"
        data.age=58;
        return this.girl.update(id,data)
     }
     getGirls(){
        return this.girl.find();
     }
     getGirlByName(name:string){
        return this.girl.find({
            where:{
                name:Like(`%${name}%`)
            }
        })
     }
}
